package com.qf.blogsystem.controller.website;

import com.qf.blogsystem.core.controller.BaseServlet;
import com.qf.blogsystem.service.DiscussPostService;
import com.qf.blogsystem.service.impl.DiscussPostServiceImpl;
import com.qf.blogsystem.vo.DiscussPostVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet("/IndexServlet/*")
public class IndexServlet extends BaseServlet {
    /**
     * 创建帖子业务层实现对象
     */
    private DiscussPostService discussPostService = new DiscussPostServiceImpl();

    /**
     * 获取所有帖子信息并响应
     * @throws Exception
     */
    public void showDiscussPost() throws Exception {
        //获取数据
        List<DiscussPostVo> list = discussPostService.discussPostList();
        //放到Map中
        Map<String, Object> map = new HashMap();
        map.put("discussPostVo", list);
        //跳转到视图
        outView("view/index", map);
    }
}
